<?php
header("Content-Type: text/html; charset=ISO-8859-1",true);
if(!isset($_SESSION))session_start();
if(!isset($_SESSION['usuario'])){
	session_destroy();
	header("location:index.php"); exit;
	}


include 'classes/crud.php';
$con = new Crud();
$con->connect();


$q = mysql_real_escape_string( $_GET['q'] );

$sql = "SELECT nome FROM categorias where locate('$q',nome) > 0 and heranca is not null order by locate('$q',nome) limit 10";

$res = mysql_query($sql);

while( $campo = mysql_fetch_array( $res ) )
{
	//echo "Id: {$campo['id']}\t{$campo['sigla']}\t{$campo['estado']}<br />";
   //	$id = $campo['id'];
	$estado = $campo['nome'];
   //$sigla = $campo['sigla'];
	//$estado = addslashes($estado);
	$html = preg_replace("/(" . $q . ")/i", "<span style=\"font-weight:bold\">\$1</span>", $estado);
	var_dump($html);
	//echo "<li onselect=\"this.setText('$estado').setValue('$id','$estado','$sigla');\">$html ($sigla)</li>\n";
    echo "<li onselect=\"this.setText('$estado');\">$html</li>\n";
}

?>